package com.etennis.controller;

import com.etennis.pojos.ResponseResult;
import com.etennis.pojos.dto.app.MediaDTO;
import com.etennis.pojos.vo.app.MediaVO;
import com.etennis.service.IMediaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/app/media")
@Slf4j
@Api(tags = "用户端-精彩瞬间接口")
public class MediaController {
    @Autowired
    IMediaService mediaService;

    @GetMapping
    @ApiOperation("精彩瞬间")
    public ResponseResult<List<MediaVO>> mediaList(){
        List<MediaVO> list=mediaService.mediaList();
        return ResponseResult.okResult(list);
    }

    @PostMapping("/upload")
    @ApiOperation("上传精彩瞬间")
    public ResponseResult uploadMedia(MediaDTO mediaDTO){
        mediaService.saveMedia(mediaDTO);
        return ResponseResult.okResult();
    }
}
